package com.packer.controller;

import com.packer.pojo.User;
import com.packer.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/user")
public class UserController {



	@Autowired
	private IUserService userService;

	@RequestMapping("/showUser")
	@ResponseBody
	public String toIndex(HttpServletRequest request) {
		return "showUser";
	}

	
	@RequestMapping(value = "/show/{id}", method = RequestMethod.GET)
	public @ResponseBody User getJson (@PathVariable(value="id") Integer id) {
		User user = this.userService.getUserById(id);
		System.out.print(user.toString());
		return user;
	}
}